package kuzmenkov.oip.model.dao.hibernate.impl;

import kuzmenkov.oip.model.Module;
import kuzmenkov.oip.model.MethodClass;
import kuzmenkov.oip.model.dao.hibernate.ModuleDao;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Expression;

/**
 * User: Michael Kuzmenkov
 * Date: 16.03.2009
 * Time: 12:05:03
 */
public class ModuleDaoImpl extends GenericDaoImpl<Module, Long> implements ModuleDao {

    public List<Module> findByMethodClass(Long methodClassId) throws DataAccessException {
        DetachedCriteria criteria = DetachedCriteria.forClass(Module.class);
        criteria.add(Expression.eq("methodClassId", methodClassId));

        List<Module> modules = getHibernateTemplate().findByCriteria(criteria);

        return modules;        
    }
}